<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundle.ListTipoTelefoneTitle}"></h:outputText>
        </ui:define>
        
        <ui:define name="menuLateral">
            
            <h:form id="formLateralMenuTipoTelefone">
                
            </h:form>
            
        </ui:define>
        
        <ui:define name="body">
            <h:form id="formTipoTelefoneList" >

                <h:panelGroup id="messagePanel" layout="block">
                    <p:growl />
                </h:panelGroup>

                <h:panelGroup>
                    <p:dataTable id="tableTipoTelefone" value="#{tipoTelefoneController.items}" emptyMessage="#{bundle.ListTipoTelefoneEmpty}" var="item" 
                                 style="border:solid 1px" paginator="true" rows="10">

                        <f:facet name="header">#{bundle.ListTipoTelefoneTitle}</f:facet>

                        <p:column sortBy="#{item.descricao}" filterBy="#{item.descricao}">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListTipoTelefoneTitle_descricao}"/>
                            </f:facet>
                            <h:outputText value="#{item.descricao}"/>
                        </p:column>
                        <p:column sortBy="#{item.operadora.descricao}" filterBy="#{item.operadora.descricao}">
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListTipoTelefoneTitle_operadora}"/>
                            </f:facet>
                            <h:outputText value="#{item.operadora.descricao}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <p:commandButton actionListener="#{tipoTelefoneController.prepareCreate}" value="#{bundle.ListTipoTelefoneCreateLink}" 
                                                 update=":formTipoTelefoneCreate:pgTipoTelefoneCreate" oncomplete="dialogTipoTelefoneCreate.show()"/>
                            </f:facet>
                            <p:commandButton actionListener="#{tipoTelefoneController.prepareEdit}" value="#{bundle.ListTipoTelefoneEditLink}" 
                                             update=":formTipoTelefoneEdit:pgTipoTelefoneEdit" oncomplete="dialogTipoTelefoneEdit.show()"/>
                            <p:commandButton actionListener="#{tipoTelefoneController.destroy}" value="#{bundle.ListTipoTelefoneDestroyLink}" ajax="false" />
                        </p:column>
                    </p:dataTable>
                </h:panelGroup>
            </h:form>

            <h:form id="formTipoTelefoneCreate">

                <p:dialog header="Nova Tipo de Telefone" widgetVar="dialogTipoTelefoneCreate" resizable="false" modal="true" showEffect="slide">
                    <p:panelGrid id="pgTipoTelefoneCreate" columns="2">
                        <h:outputLabel value="#{bundle.CreateTipoTelefoneLabel_descricao}" for="descricao" />
                        <p:inputText id="descricao" value="#{tipoTelefoneController.selected.descricao}" 
                                     title="#{bundle.CreateTipoTelefoneTitle_descricao}" required="true" 
                                     requiredMessage="#{bundle.CreateTipoTelefoneRequiredMessage_descricao}"/>
                        <h:outputLabel value="#{bundle.CreateTipoTelefoneLabel_operadora}" for="operadora" />
                        <p:selectOneMenu id="operadora" value="#{tipoTelefoneController.selected.operadora}" 
                                         label="#{bundle.CreateTipoTelefoneTitle_operadora}" required="true" 
                                         requiredMessage="#{bundle.CreateTipoTelefoneRequiredMessage_operadora}">
                            <f:selectItems value="#{operadoraController.itemsAvailableSelectOne}"/>
                        </p:selectOneMenu>
                        <p:commandButton actionListener="#{tipoTelefoneController.create}" 
                                         update=":formTipoTelefoneList:tableTipoTelefone" 
                                         value="#{bundle.CreateTipoTelefoneSaveLink}" 
                                         oncomplete="#{tipoTelefoneController.prepareCreate}" ajax="false" />
                        <p:commandButton value="Limpar" type="reset" 
                                         update=":formTipoTelefoneCreate:pgTipoTelefoneCreate" ajax="false"/>
                    </p:panelGrid>
                </p:dialog>

            </h:form>

            <h:form id="formTipoTelefoneEdit">

                <p:dialog header="Editar Tipo de Telefone" widgetVar="dialogTipoTelefoneEdit" resizable="false" 
                          modal="true" showEffect="slide">
                    <p:panelGrid id="pgTipoTelefoneEdit" columns="2">
                        <h:outputLabel value="#{bundle.CreateTipoTelefoneLabel_descricao}" for="descricao" />
                        <p:inputText id="descricao" value="#{tipoTelefoneController.selected.descricao}" 
                                     title="#{bundle.CreateTipoTelefoneTitle_descricao}" required="true" 
                                     requiredMessage="#{bundle.CreateTipoTelefoneRequiredMessage_descricao}"/>
                        <h:outputLabel value="#{bundle.CreateTipoTelefoneLabel_operadora}" for="operadora" />
                        <p:selectOneMenu id="operadora" value="#{tipoTelefoneController.selected.operadora}" 
                                         label="#{bundle.CreateTipoTelefoneTitle_operadora}" required="true" 
                                         requiredMessage="#{bundle.CreateTipoTelefoneRequiredMessage_operadora}">
                            <f:selectItems value="#{operadoraController.itemsAvailableSelectOne}"/>
                        </p:selectOneMenu>
                        <p:commandButton actionListener="#{tipoTelefoneController.update}" 
                                         update=":formTipoTelefoneList:tableTipoTelefone" 
                                         value="#{bundle.EditTipoTelefoneSaveLink}" 
                                         oncomplete="dialogTipoTelefoneEdit.hide()" ajax="false" />
                        <p:commandButton value="Cancelar" oncomplete="dialogTipoTelefoneEdit.hide()" ajax="false"/>
                    </p:panelGrid>
                </p:dialog>

            </h:form>
        </ui:define>
    </ui:composition>

</html>
